home *** CD-ROM | disk | FTP | other *** search
- class Algae extends State
- {
- var mcRef;
- var nCountDown;
- var sState;
- static var sLINKAGE_NAME = "mcAlgae";
- var sSTATE_IDLE = "Idle";
- var sSTATE_CATCHING = "Catching";
- var sSTATE_CAUGHT = "Caught";
- var sSTATE_FALLING = "Falling";
- var sSTATE_FALLEN = "Fallen";
- var sSTATE_RETURN = "Return";
- var nMAX_COUNTDOWN = 200;
- static var nCOUNTER = 0;
- static var nMIN_DEPTH = 200012;
- static var nSUBSTRACT_DEPTH = 200000;
- static var nDEPTH_FACTOR = 25;
- static var nMIN_WAIT_TIME = 50;
- static var nMAX_WAIT_TIME = 250;
- function Algae(_nX, _nY)
- {
- super(CTRLGame.getRef().mcRef.attachMovie(Algae.sLINKAGE_NAME,Algae.sLINKAGE_NAME + Algae.nCOUNTER,this.calculateDepth(_nY,CTRLGame.nALGAE_ADD + Algae.nCOUNTER)));
- Algae.nCOUNTER = Algae.nCOUNTER + 1;
- this.mcRef._x = _nX;
- this.mcRef._y = _nY;
- this.setIdleState();
- this.nCountDown = 0;
- if(Controller.getRef().isPaused())
- {
- this.doPause();
- }
- }
- function cleanUp()
- {
- super.cleanUp();
- this.mcRef.swapDepths(7777);
- this.mcRef.removeMovieClip();
- }
- function catchBus()
- {
- this.setState(this.sSTATE_CATCHING);
- }
- function setInactive()
- {
- this.setState(this.sSTATE_FALLING);
- this.nCountDown = this.nMAX_COUNTDOWN;
- this.mcRef.swapDepths(this.mcRef.getDepth() - Algae.nSUBSTRACT_DEPTH);
- }
- function isInactive()
- {
- return this.sState != this.sSTATE_IDLE;
- }
- function setIdleState()
- {
- var _loc2_ = Math.round(Math.random() * 42) + 1;
- this.setState(this.sSTATE_IDLE);
- this.mcRef.mcState.gotoAndPlay(_loc2_);
- }
- function calculateDepth(_nY, _nAdd)
- {
- var _loc4_ = Math.round(_nY) * Algae.nDEPTH_FACTOR + Algae.nMIN_DEPTH + _nAdd;
- return _loc4_;
- }
- function Idle()
- {
- }
- function Catching()
- {
- if(this.stateFinished())
- {
- this.setState(this.sSTATE_CAUGHT);
- }
- }
- function Caught()
- {
- }
- function Falling()
- {
- if(this.stateFinished())
- {
- this.setState(this.sSTATE_FALLEN);
- }
- }
- function Fallen()
- {
- if(!Controller.getRef().isPaused() && !CTRLGame.getRef().Screen.isInMiniGame())
- {
- this.nCountDown = this.nCountDown - 1;
- if(this.nCountDown <= 0)
- {
- this.setState(this.sSTATE_RETURN);
- }
- }
- }
- function Return()
- {
- if(this.stateFinished())
- {
- this.setIdleState();
- this.mcRef.swapDepths(this.mcRef.getDepth() + Algae.nSUBSTRACT_DEPTH);
- }
- }
- }
-